<template>
  <div id="app" >
    <index ref="page"></index>
    <loading></loading>
    <tip></tip>
  </div>
</template>

<script>
  console.log(window.location.href)
  import Loading from '@/components/common/Loading'
  import Tip from '@/components/common/Tip'
  import remoteDAO from '@/common/remoteDAO'
  import localDAO from '@/common/localDAO'
  import {getUrlParam} from '@/common/common'
  import index from 'components/index/index'
  export default {
    name: 'app',
    data () {
      return {
      }
    },
    components: {
      index,
      Loading, // loading弹窗
      Tip
    },
    methods: {
      appInit () {
        return new Promise((resolve, reject) => {
          if (getUrlParam('userCode')) {
            localDAO.saveUserCode(getUrlParam('userCode'))
            resolve()
          } else {
            remoteDAO.getUserCode(this.$store).then((res) => {
              localDAO.saveUserCode(res)
              resolve()
            }).catch((err) => {
//              alert('获取用户代码失败！')
              reject(err)
            })
          }
        })
      }
    },
    mounted () {
      this.appInit().then(() => {
        this.$refs.page.init()
      })
//      remoteDAO.callUC12000022('600814').then((res) => {
//        console.log(res, '0000000aaaaaa')
//      })
    }
  }
</script>

<style lang="less">
  html, body{
    perspective: 1200px;
    height: 100%;
  }
  #app {
    font-family:Helvetica, 'Avenir', PingFangSC-Regular, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    background-color: white;
    height:100%;
    width: 100%;
  }

</style>
